---
description: GraphQL Inspector - There are a few options to provide your schema in GraphQL Inspector.
---
import { Callout, Tabs } from '@theguild/components'

# Providing Schema

There are a few options to provide your schema in GraphQL Inspector.

## JavaScript And TypeScript File

GraphQL Inspector accepts CommonJS and ESModules

<Tabs items={['CommonJS', 'ESM default export', 'ESM named export']}>
<Tabs.Tab>
```js
// Example for loading and merging multiple .graphql files into a single schema
const { makeExecutableSchema } = require('@graphql-tools/schema')
const { loadFilesSync } = require('@graphql-tools/load-files')

const typeDefs = loadFilesSync('**/*.graphql')

module.exports = makeExecutableSchema({ typeDefs })
```
</Tabs.Tab>
<Tabs.Tab>
```ts
import { makeExecutableSchema } from '@graphql-tools/schema'
import { typeDefs } from './type-defs'

// as `default`
export default makeExecutableSchema({ typeDefs })
```
</Tabs.Tab>
<Tabs.Tab>
```ts
import { makeExecutableSchema } from '@graphql-tools/schema'
import { typeDefs } from './type-defs'

// as `schema` variables
export const schema = makeExecutableSchema({ typeDefs })
```
</Tabs.Tab>
</Tabs>

If you need to transpile a file, use `--require` option of the CLI:
```sh /--require/
graphql-inspector introspect ./schema.ts --require ts-node/register
```
## GraphQL File

Files with those extensions: `.graphql`, `.graphqls` or `.gql` are supported by GraphQL Inspector.

```sh
graphql-inspector diff ./old-schema.graphql ./new-schema.gql
```

## JSON File

A JSON file with introspection results can also be provided:

```sh
graphql-inspector diff ./old-schema.json ./new-schema.json
```

## GraphQL Endpoint

GraphQL Inspector can also introspect your GraphQL server:

```sh
graphql-inspector diff http://api.com/graphql ./new-schema.json
```

## Git Repository

Get GraphQL Schema file from any branch or commit of your git repository:

```sh
git:origin/branch:path/to/file
```

For example, you want to get `schema.graphql` from `origin/master`:

```sh
git:origin/master:./schema.graphql
```

## GitHub Repository

Yes, GraphQL Inspector can also do that, here's the pattern:

```sh
github:owner/name#ref:path/to/file
```

- `github` - stays there, it tells Inspector we want to use GitHub
- `owner` - your GitHub username or organization
- `name` - repository's name
- `ref` - can be the name of a branch or commit sha
- `path/to/file` - where Inspector can find the GraphQL file

For example, we want to fetch a .graphql file from master branch of
[this sample repository](https://github.com/kamilkisiela/graphql-inspector-example/blob/master/schema.graphql):

```sh
github:kamilkisiela/graphql-inspector-example#master:./schema.graphql --token 'github-token-here'
```

<Callout type="warning">
  GitHub Loader requires a GitHub token to be defined!
</Callout>

## Programmatic API

If you are using programmatic API, you might find `@graphql-tools/load` package useful for loading schemas. Learn more
[here](https://graphql-tools.com/docs/schema-loading).
